# 1 实例化类 SweetPotato
# init 函数 cook_time  cook_state condiments
# cook 地瓜被烤函数
# add_condiments 添加调料
# str魔法方法

# 2 用类实例化对象
# 不断的烤地瓜/添加调料, 打印对象状态

class SweetPotato:
    def __init__(self):
        self.cook_time = 0
        self.cook_state = "生的"
        self.condiments = []

    def cook(self, time):
        self.cook_time += time
        if 0<= self.cook_time < 3:
            self.cook_state = "生的"

        elif 3<= self.cook_time < 7:
            self.cook_state = "半生不熟"

        elif 7<= self.cook_time < 12:
            self.cook_state = "熟了"

        elif self.cook_time >= 12:
            self.cook_state = "糊了"

    def add_condiments(self, condiment):
        self.condiments.append(condiment)

    def __str__(self):
        return f"烤时间:{self.cook_time}, 状态{self.cook_state}, 调料{self.condiments}"


if __name__ == '__main__':

    # 1 实例化对象
    sweetpotato = SweetPotato()  # cmd+shift+u
    print(sweetpotato)

    # 2 烤2分钟
    sweetpotato.cook(2)
    sweetpotato.add_condiments('酱油')
    print(sweetpotato)

    # 3 再烤3分钟
    sweetpotato.cook(3)
    sweetpotato.add_condiments('辣椒儿')
    print(sweetpotato)

    # 4
    sweetpotato.cook(2)
    print(sweetpotato)

    # 5
    sweetpotato.cook(21)
    print(sweetpotato)



